home *** CD-ROM | disk | FTP | other *** search
- /* */
-
- signal on break_c
-
- /*LIBRARIES*/
- if ~show("L","rmh.library") then
- if ~addlib("rmh.library",0,-30) then do
- say "no rmh.library"
- exit
- end
- if ~show("L","rxsocket.library") then
- if ~addlib("rxsocket.library",0,-30) then do
- say "no rxsocket.library"
- exit
- end
- if ~show("L","rxmiamibpf.library") then
- if ~addlib("rxmiamibpf.library",0,-30) then do
- say "no rxmiamibpf.library"
- exit
- end
-
- /*ARGUMENTS*/
- prg=ProgramName("NOEXT")
- if ~RMH_ReadArgs("INTERFACE") then do
- call PrintFault(IoErr(),prg)
- exit
- end
-
- if parm.0.flag then do
- interface=parm.0.value
- res=IsOnLine(parm.0.value)
- if res<0 then call err "interface '"interface"' doesn't exist"
- if res==0 then call err "interface '"interface"' is not up"
- end
- else interface=""
-
- ctrlc=2**12
- bpfa.device = interface
- bpfa.BuffLen = 256
- bpfa.Immediate = 1
- bpfa.AbortMask = ctrlc
- bpfa.Filter = "udp and dst port 31337"
- bpf=MiamiBPFOpen("BPFA")
- if bpf<0 then call err BPFERR
-
- call MiamiBPFIoctlGet(bpf,"D","DEVICE")
- say "Listening for BackOrifice connection on device: '"d"'"
-
- cs = MiamiBPFSignalmask(bpf)
- call MiamiBPFSetAbortMask(bpf,ctrlc)
- sig=or(cs,ctrlC)
-
- do while 1
- call MiamiBPFIoctlGet(bpf,"BS","FIONREAD")
- if bs<=0 then res=Wait(sig)
- else if CheckSignal(ctrlc) then res = ctrlc
- else res=0
- if and(res,ctrlc)~=0 then signal break_c
- call MiamiBPFIoctlGet(bpf,"BS","FIONREAD")
- if bs>0 then do
- l=MiamiBPFRead(bpf,"PKT")
- if l>0 then call parsePkt(pkt)
- end
- end
-
- rresolve: procedure
- parse arg ip
- if ~GethostByAddr("H",ip) then return ip
- return h.hostname
-
- parsepkt:
- parse arg pkt
-
- call ReadIP(pkt,"IPH")
- call readUDP(substr(pkt,21,100),"UDPH")
- from=rresolve(iph.src)
- fromPort=udph.sport
- call SysLog("BackOrifice connection from ["from":"fromPort"]")
- return
-
- break_c:
- exit
-
- err: procedure expose prg
- parse arg msg
- say prg":" msg
- exit
-